<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .active {
            color: red;
        }
    </style>
</head>
<body>
    <div id="app"></div>

    <template id="my-app">
        <!-- 对象语法 -->
        <!-- 为false的时候,这个类就不会绑定 -->
      <div :class="{'active': isActive}">
        盖伦
      </div>
      <button @click="toggle">change</button>

      <!-- 也可也有多个键值对 -->
      <!-- 类名的单引号可以不加 -->
      <div :class="{'active': isActive, 'title': true}">一号</div>
      <div :class="classObj">一号</div>
      <div :class="getClassObj()">一号</div>
      <div :class="['def', title, {active, isActive}]">一号</div>


    </template>

    <script src="../vue/vue.js"></script>
    <script>
        const App = {
            template: '#my-app',
            data() {
                return {
                    message: 'hello',
                    isActive: true,
                    title: 'abc',
                    classObj: {'active': true, 'title': true}
                }
            },
            methods: {
                toggle() {
                    this.isActive = !this.isActive
                },
                getClassObj() {
                    return {'active': true, 'title': true}
                }
            }
        }

        Vue.createApp(App).mount('#app');
    </script>
</body>
</html>